﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HideBanner
{
    public class HideBanner : IPlugin.IPlugin
    {
        #region InfoPlugin

        public string[] Authors
        {
            get
            {
                return new string[] { "Manuel Fernandez" };
            }
        }

        public string Name
        {
            get
            {
                return "HideBanner";
            }
        }

        public string Description
        {
            get
            {
                return "Changes the server header replacing it for a personalized banner. Also removes other headers such as X-Powered-By";
            }
        }

        public IPlugin.PluginRing Ring
        {
            get
            {
                return IPlugin.PluginRing.Ring0;
            }
        }
        #endregion

        public Model.Elements.HttpPacket Start(Model.Elements.HttpPacket packet)
        {

            string banner = "ProxyMe";

            if (packet is Model.Elements.HttpResponsePacket)
            {
                Model.Elements.HttpResponsePacket response = packet as Model.Elements.HttpResponsePacket;
                response.RemoveHeader("server", false);
                response.RemoveHeader("X-Powered-By", false);
                response.AddHeader(new Model.Elements.HttpHeader("Server", banner));
                return response;
            }

            return packet;
        }
    }
}
